package org.jsbd.boss.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.dao.INewExecutionGroupDAO;
import org.jsbd.boss.domian.NewExecutionGroup;
import org.jsbd.boss.domian.NewExecutionGroupMark;
import org.jsbd.boss.domian.NewExecutionGroupMarkVO;
import org.jsbd.boss.domian.channel.NewExecutionGroupMarkDto;
import org.springframework.stereotype.Repository;

import edu.hziee.common.dbroute.BaseDAO;

@Repository("newExecutionGroupDao")
public class NewExecutionGroupDAOImpl extends BaseDAO implements INewExecutionGroupDAO {

	@Override
	public Map<String, Object> selectGroupListWithPage(DataGridModel page, NewExecutionGroupMarkDto dto) {
		dto = (dto == null ? new NewExecutionGroupMarkDto() : dto);
		dto.setPageInfo(page);
		Map<String, Object> results = new HashMap<String, Object>();
		results.put("rows", super.queryForList("qy_new_execution_group.SELECT_GROUP_LIST", dto));
		results.put("total", super.queryForCount("qy_new_execution_group.SELECT_GROUP_COUNT", dto));
		return results;
	}

	@Override
	public List<NewExecutionGroupMark> selectGroupDetailById(Integer groupId) {
		return super.queryForList("qy_new_execution_group.SELECT_GROUP_DETAIL_BY_ID", groupId);
	}

	@Override
	public void insertGroup(NewExecutionGroup newExecutionGroup) {
		super.insert("qy_new_execution_group.INSERT_GROUP", newExecutionGroup);
	}

	@Override
	public NewExecutionGroup selectGroupById(Integer id) {
		return (NewExecutionGroup) super.queryForObject("qy_new_execution_group.SELECT_GROUP_BY_ID", id);
	}

	@Override
	public void updateGroup(NewExecutionGroup newExecutionGroup) {
		super.update("qy_new_execution_group.UPDATE_GROUP", newExecutionGroup);
	}

	@Override
	public List<NewExecutionGroupMark> selectGroupMarkById(Integer id) {
		return super.queryForList("qy_new_execution_group.SELECT_GROUP_MARK_BY_ID", id);
	}

	@Override
	public void deleteGroup(Integer id) {
		super.delete("qy_new_execution_group.DELETE_GROUP", id);
	}

	@Override
	public void insertGroupMark(NewExecutionGroupMark newExecutionGroupMark) {
		super.insert("qy_new_execution_group.INSERT_GROUP_MARK", newExecutionGroupMark);
	}

	@Override
	public void deleteGroupMark(Integer id) {
		super.delete("qy_new_execution_group.DELETE_GROUP_MARK", id);
	}

	@Override
	public List<NewExecutionGroupMarkVO> selectSearchDataByGroupId(NewExecutionGroupMarkDto negmDto) {
		return super.queryForList("qy_new_execution_group.SELECT_SEARCH_DATA_BY_GROUP_ID", negmDto);
	}

	@Override
	public List<NewExecutionGroupMarkVO> selectSearchDataTotalByGroupId(NewExecutionGroupMarkDto negmDto) {
		return super.queryForList("qy_new_execution_group.SELECT_SEARCH_DATA_TOTAL_BY_GROUP_ID", negmDto);
	}

	@Override
	public NewExecutionGroupMark selectMarkByGroupIdAndMark(Integer id, String mark) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("id", id);
		map.put("mark", mark);
		return (NewExecutionGroupMark) super.queryForObject("qy_new_execution_group.SELECT_MARK_BY_GROUP_ID_AND_MARK", map);
	}

	@Override
	public NewExecutionGroup selectGroupByName(String groupName) {
		return (NewExecutionGroup) super.queryForObject("qy_new_execution_group.SELECT_GROUP_BY_NAME", groupName);
	}

}
